﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RL = Bettzueche.RLLibrary.Types;

namespace RLProject1.Model.AMEEWorld
{
    class TiliCoding2
    {
        const int OST = 0;
        const int NORD = 1;
        const int WEST = 2;
        const int SUD = 3;
        const int ZRichtungCount = 4;
        int _featureCount;

        void Init() {
            // dim⁡(Φ_2 )=|U_Ab |+|Z|=|U|∙|Ab|+|Z|=4∙8+4=36
            // für n=8 Abschnitte eine U-Tiling
            //...
            int _A_ = 8;
            int tilingsCnt = 4;

            RL.MultiTiling[] uTilings = new RL.MultiTiling[_A_];

            _featureCount = 0;
            for (int i = 0; i < _A_; i++) {
                //RL.MultiTiling uAb_n = new RL.MultiTiling(tilingsCnt, precision:0.1, min:0.0, max:1.0);
                var uAb_n = new RL.MultiTiling(tilingsCnt, precision: 0.1, min: 0.0, max: 1.0,
                    startIndex: _featureCount, name: "uAb" + (i+1).ToString());
                _featureCount += uAb_n.TileCount;
            }
            _featureCount += 4; // für die Zielrichtungen


            // Get FeatureSet............................
            double[] uMeasured = { .1, .2, .3, .4, .5, .6, .7, .8 };
            int zRichtung = NORD;

            // für jedes Tiling FeatureSet holen, anschließend zusammenführen.
            List<int> featureSet = new List<int>();
            for (int i = 0; i < uTilings.Length; i++) {
                var fSet_n = uTilings[i].GetFeatureNumbers(uMeasured[i]);
                featureSet.AddRange(fSet_n);
            }
            // + Feature der Zielrichtung
            featureSet.Add(_featureCount - ZRichtungCount + zRichtung);
            int[] features = featureSet.ToArray();
            //.................................................
        }

    }
}
